package com.example.vuebackend.controller;

import com.example.vuebackend.dto.BookNumInfo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

@Controller
public class BookController {

    List<BookNumInfo> list = new ArrayList<>();
    int count = 1;

    @RequestMapping(value = "/", method = RequestMethod.GET)
    public String index() {
        return "index";
    }
    //查询符合条件的书籍
    @RequestMapping(value = "/book_search", method = RequestMethod.GET)
    public String  queryBook(@RequestParam(value = "searchBook") String searchBook, Model model){
        list.clear();
        for (int i = 0; i < 5; i++) {
            list.add(new BookNumInfo("Name" + count,"" + count++));
        }
        //将书籍投票作为对象返回到前端
        model.addAttribute("bookRecordes",list);
        return "index::book_recorde";
    }



}
